package domfarr.collections;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class RemoveFromCollection {

	public static void main(String[] args) {

		Collection<String> mySet = new HashSet<String>();
		mySet.add("one");
		mySet.add("two");
		mySet.add("three");
		mySet.add("four");

		Iterator<String> iterator = mySet.iterator();

		while(iterator.hasNext()) {
			String item = iterator.next();
			if (item.startsWith("t")) {
				iterator.remove();
			}
		}

		System.out.println(mySet);
	}

}
